package A1;

public class Menu{
    ProjModel pm = new ProjModel();
    GetInput gi = new GetInput();

    public void showMenu(){
         System.out.print("===Menu===\n" +
                "1. Set Number of horizontal lanes (H-street) [min 1, max 3]\n" +
                "2. Set Number of vertical lanes  (V-street) [min 1, max 4]\n" +
                "3. Set Probability of a car entering H-street [min 0, max 1]\n" +
                "4. Set Probability of a car entering V-street [min 0, max 1]\n" +
                "5. Run one simulation cycles\n" +
                "6. Set and run number of simulation cycles [min 1, max 10]\n" +
                "7. Exit\n" +
                "Enter your choice> ");
         gi.setChoice();
         int option = gi.getChoice();

         switch(option){
            case 1: System.out.println("Menu 1\n"
                    + "Please enter Number of Lanes(min 1, max 3): ");
                    do{gi.setChoice();
                    pm.setHorLanes(gi.getChoice());
                        if (ProjModel.getHorLanes() >3 || ProjModel.getHorLanes() <1){
                            System.out.println("Error!\n" + "MIN: 1, MAX: 3!");
                        }
                    }while (ProjModel.getHorLanes() >3 || ProjModel.getHorLanes() <1);
                    System.out.println("Number of Horizontal Lanes: "+ ProjModel.getHorLanes());
                    break;

            case 2: System.out.println("Menu 2\n"
                    + "Please enter Number of Lanes(min 1, max 4): ");
                    do{gi.setChoice();
                    pm.setVerLanes(gi.getChoice());
                        if (ProjModel.getVerLanes() >4 || ProjModel.getVerLanes() <1){
                            System.out.println("Error!\n" + "MIN: 1, MAX: 4!");
                        }
                    }while (ProjModel.getVerLanes() >4 || ProjModel.getVerLanes() <1);
                    System.out.println("Number of Vertical Lanes: "+ ProjModel.getVerLanes());
                    break;

            case 3: System.out.println("Menu 3\n" + "Please enter the probability of car entering h lane (min 0, max 1): ");
                    do{gi.setProb();
                    pm.setProbHLane(gi.getProb());
                        if (ProjModel.getProbHLane() >1 || ProjModel.getProbHLane() <0){
                            System.out.println("Error!\n" + "MIN: 0, MAX: 1!");
                        }
                    }while (ProjModel.getProbHLane() >1 || ProjModel.getProbHLane() <0);
                    System.out.println("Probability of car entering h lane: "+ProjModel.getProbHLane());
                    break;

            case 4: System.out.println("Menu 4\n" + "Please enter the probability of car entering v lane (min 0, max 1): ");
                    do{gi.setProb();
                    pm.setProbVLane(gi.getProb());
                        if (ProjModel.getProbVLane() >1 || ProjModel.getProbVLane() <0){
                            System.out.println("Error!\n" + "MIN: 0, MAX: 1!");
                        }
                    }while (ProjModel.getProbVLane() >1 || ProjModel.getProbVLane() <0);
                    System.out.println("Probability of car entering v lane: "+ProjModel.getProbVLane());
                    break;

            case 5: System.out.println("Menu 5");
                    pm.setCycle(1);
                    pm.printCycle();
                    break;

            case 6: System.out.println("Menu 6\n" + "Please enter number of cycles (min 1; max 10): ");
                    do{gi.setChoice();
                        if(gi.getChoice() > 10 || gi.getChoice() < 1){
                            System.out.println("Error!\n" + "MIN: 0, MAX: 10!");
                        }
                    }while(gi.getChoice() > 10 || gi.getChoice() < 1);
                    pm.setCycle(gi.getChoice());
                    pm.printCycle();
                    break;

            case 7: System.out.println("Thank You!");
                    System.exit(1);
                    break;

            default: System.out.println("Input Error!");
    }
    }
}
    